package org.uk.splitsbrowser.server;

import com.orientechnologies.orient.object.db.OObjectDatabasePool;
import com.orientechnologies.orient.object.db.OObjectDatabaseTx;
import org.uk.splitsbrowser.shared.*;

public class DBService {
	
	private static boolean classesRegistered = false;
	
	public static OObjectDatabaseTx getDB()  {
		// get a database instance of the from the connection pool
		  OObjectDatabaseTx db= OObjectDatabasePool.global().acquire("local:C:\\Users\\ryderd\\orientdb_data\\splitsbrowserdb", "admin", "admin");
		  
		  registerClasses(db);
		  
		  return (db); 
		  
	}
	  private static void registerClasses(OObjectDatabaseTx db){
		  if (!classesRegistered) {
			  db.getEntityManager().registerEntityClass(OEvent.class);
			  db.getEntityManager().registerEntityClass(User.class);

		  } 

	  }


}
